{% load staticfiles %}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Code</title>
    <style>
        .hide{
            display: none;
        }
        .loading{
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background-color: black;
            opacity: 0.3;
        }
        .loading-icon{
            width: 100px;
            height: 30px;
            position: fixed;
            top: 50%;
            left: 50%;
            margin-left: -50px;
            margin-top: -15px;
        }
    </style>
</head>
<body>
    <h1>获取代码</h1>
    <p>
        <input type="text" name="repo" id="repo">
        <input type="text" name="project" id="project">
        <input type="button" value="获取" onclick="downloadRepo()">
    </p>

    <div id="loading" class="loading hide">
        <div class="loading-icon">
            <img src="{% static 'loading.gif' %}" alt="">
        </div>
    </div>

</body>
<script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js"></script>
    <script>
        function downloadRepo() {
            $('#loading').removeClass('hide');
            var repo = $('#repo').val();
            var project = $('#project').val();
            $.ajax({
                url:'/fetch/code/',
                type:'POST',
                data:{repo:repo,project:project},
                success:function (arg) {
                    $('#loading').addClass('hide');
                },
                eroor:function (arg) {
                    $('#loading').addClass('hide');
                }
            })
        }
    </script>
</html>